﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true"
 CodeBehind="CreateTournament.aspx.cs" Inherits="Nivdal.CreateTournament" Theme="SkinFile" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="AjaxTK" %>
<%@ Register Assembly="obout_Flyout2_NET" Namespace="OboutInc.Flyout2" TagPrefix="cc1" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadPlaceHolder" runat="server">
    <script type="text/javascript" language="javascript">
        function GeneratePassword() {
            var pwd = Math.floor(Math.random() * 900000) + 100000;
            $("#ctl00_ctl00_ContentPlaceHolder3_ContentPlaceHolder1_TournamentPasswordTextBox").val(pwd);
        }

        function ToggleSignupDiv(setting) {
            if (setting == '1')
                $("#passworddiv").show();
            else {
                $("#ctl00_ctl00_ContentPlaceHolder3_ContentPlaceHolder1_TournamentPasswordTextBox").val("");
                $("#passworddiv").hide();
            }
        }

        function PrizesCheck(Id) {
            var radios = document.getElementsByTagName("input");
            for (i = 0; i < radios.length; i++) {
                if ((radios[i].type == "radio") && (radios[i].name.match("PrizesSets"))) {
                    var match_str = "ctl0" + Id + "_SelectedRB";
                    if (!radios[i].id.match(match_str)) {
                        radios[i].checked = false;
                    }
                }
            }

        }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
        <ContentTemplate>
        
        <asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePanel1">
            <ProgressTemplate>
                <div class="ajaxloader">
                    <asp:Image ID="Progressimage" runat="server" ImageURl="~/Images/ajax-loader.gif" />
                </div>
            </ProgressTemplate>
        </asp:UpdateProgress>
        
        <div class="basic_element">
        <div class="red_title">
           <asp:Label ID="TitleLabel" runat="server" CssClass="white_title" Text="<%$ Resources:Resource, CreateTournament_PageTitle %>"></asp:Label>
        </div>
        <div class="padding5">

            <asp:Label ID="ErrorLabel" runat="server" SkinID="RedConfirmLabel" Text="<%$ Resources:Resource, CreateTournament_PageTitle %>"></asp:Label>
            <br />
            <asp:Panel ID="CannotOpenPanel" runat="server">
                <asp:Label ID="CannotOpenLabel" runat="server" SkinID="GridLabel" Text="<%$ Resources:Resource, CreateTournament_PageTitle %>"></asp:Label>
            </asp:Panel>

            <asp:Panel ID="Stage1Panel" runat="server">
                <table cellpadding="5" cellspacing="0">
                <tr>
                <td>
                    <asp:Label ID="TournamentNameTitleLabel" runat="server" SkinID="InfoLabel"
                    Text="<%$ Resources:Resource, CreateTournament_TournamentNameTitle %>"></asp:Label>
                </td>
                <td>
                    <asp:TextBox ID="TournamentNameTextBox" runat="server" Width="300" MaxLength="100" TextMode="SingleLine"
                     ValidationGroup="Step1"></asp:TextBox>
                     <asp:RequiredFieldValidator ID="NameRequired" runat="server" ValidationGroup="Step1" 
                     ControlToValidate="TournamentNameTextBox" Text="*" SetFocusOnError="true"></asp:RequiredFieldValidator>
                </td>
                </tr>
                <tr>
                <td style="vertical-align:top;">
                    <asp:Label ID="TournamentTypeTitleLabel" runat="server" SkinID="InfoLabel" 
                    Text="<%$ Resources:Resource, CreateTournament_TournamentTypeTitle %>"></asp:Label>
                </td>
                <td>
                    <asp:DropDownList ID="TournamentTypeDDL" runat="server" AutoPostBack="true" DataTextField="Description" DataValueField="Type"
                     OnSelectedIndexChanged="TournamentTypeChosen" DataSourceID="TournamentTypeDataSource"></asp:DropDownList>
                </td>
                </tr>
                <tr>
                <td>
                    <asp:Label ID="NumTeamsTitleLabel" runat="server" SkinID="InfoLabel" Text="<%$ Resources:Resource, Country_NumberOfTeamsTitleLabel %>"></asp:Label>
                </td>
                <td>
                    <asp:DropDownList ID="NumTeamsDDL" runat="server"></asp:DropDownList>
                </td>
                </tr>
                <tr>
                <td style="vertical-align:top;">
                    <asp:Label ID="SignupTypeTitleLabel" runat="server" SkinID="InfoLabel" Text="<%$ Resources:Resource, CreateTournament_SignupTypeTitle %>"></asp:Label>
                </td>
                <td>
                    <asp:RadioButton ID="ClearSignupRadioButton" runat="server" Checked="true" onclick="ToggleSignupDiv('0')"
                    Text="<%$ Resources:Resource, CreateTournament_SignupTypeFree %>" GroupName="Signup" CssClass="NewsItemStyle"/>
                    <br />
                    <asp:RadioButton ID="PasswordSignupRadioButton" runat="server" GroupName="Signup" CssClass="NewsItemStyle"
                     Text="<%$ Resources:Resource, CreateTournament_SignupTypePassword %>" onclick="ToggleSignupDiv('1')" />
                 
                     <div id="passworddiv"  style="padding: 3px 0px 3px 0px;">
                        <asp:TextBox ID="TournamentPasswordTextBox" runat="server" Width="100" MaxLength="10"></asp:TextBox>

                        <asp:ImageButton ID="GeneratepasswordButton" runat="server" ImageUrl="~/Images/Icons/UnbeatenSeason.png"
                         ToolTip="<%$ Resources:Resource, CreateTournament_GeneratePasswordButttonText %>" OnClientClick="GeneratePassword(); return false;" />

                        <asp:Label ID="PleaseChoosePasswordTitleLabel" runat="server" SkinID="RedConfirmLabel"
                         Text="<%$ Resources:Resource, CreateTournament_PleaseSetPasswordText %>" Visible="false"></asp:Label>
                     </div>
                </td>
                </tr>
                <tr>
                <td colspan="2">
                    <asp:Panel ID="NationalTeamsPanel" runat="server">
                        <asp:DropDownList ID="NationalTeamsDDL" runat="server">
                            <asp:ListItem Text="Regular Teams" Value="0" Selected="True"></asp:ListItem>
                            <asp:ListItem Text="National teams" Value="1"></asp:ListItem>
                            <asp:ListItem Text="U19 teams" Value="2"></asp:ListItem>
                        </asp:DropDownList>
                    </asp:Panel>
                </td>
                </tr>
                </table>
                <br />
                <asp:Button ID="ToStep2Button" runat="server" Text="<%$ Resources:Resource, Register_ContinueButton %>"
                 CssClass="GreySmallButtonStyle" OnClick="ContinueToStep2" CausesValidation="true" ValidationGroup="Step1"/>
            </asp:Panel>
            <asp:Panel ID="Stage2Panel" runat="server" Visible="false">
                <br />
                <asp:Label ID="ChooseDatesTitleLabel" runat="server" SkinID="InfoLabel" Text="<%$ Resources:Resource, CreateTournament_ChooseTournamentDates %>"></asp:Label>
                <br />
                <asp:Repeater ID="DatesRepeater" runat="server">
                    <HeaderTemplate>
                        <table>
                        <tr><td></td><td></td></tr>
                    
                    </HeaderTemplate>
                    <ItemTemplate>
                        <tr>
                        <td>
                            <asp:HiddenField ID="SpecialNameHF" runat="server" Value='<%# Eval("SpecialName") %>' />
                            <asp:Label ID="RoundNumTitleLabel" runat="server" Text='<%# Eval("RoundText") %>' SkinID="InfoLabel"></asp:Label>
                        </td>
                        <td>
                            <asp:DropDownList ID="DaysDDL" runat="server">
                            </asp:DropDownList>
                            <asp:DropDownList ID="HourDDL" runat="server">
                                <asp:ListItem Text="00" Value="00"></asp:ListItem>
                                <asp:ListItem Text="01" Value="01"></asp:ListItem>
                                <asp:ListItem Text="02" Value="02"></asp:ListItem>
                                <asp:ListItem Text="03" Value="03"></asp:ListItem>
                                <asp:ListItem Text="04" Value="04"></asp:ListItem>
                                <asp:ListItem Text="05" Value="05"></asp:ListItem>
                                <asp:ListItem Text="06" Value="06"></asp:ListItem>
                                <asp:ListItem Text="07" Value="07"></asp:ListItem>
                                <asp:ListItem Text="08" Value="08"></asp:ListItem>
                                <asp:ListItem Text="09" Value="09"></asp:ListItem>
                                <asp:ListItem Text="10" Value="10"></asp:ListItem>
                                <asp:ListItem Text="11" Value="11"></asp:ListItem>
                                <asp:ListItem Text="12" Value="12"></asp:ListItem>
                                <asp:ListItem Text="13" Value="13"></asp:ListItem>
                                <asp:ListItem Text="14" Value="14"></asp:ListItem>
                                <asp:ListItem Text="15" Value="15"></asp:ListItem>
                                <asp:ListItem Text="16" Value="16"></asp:ListItem>
                                <asp:ListItem Text="17" Value="17"></asp:ListItem>
                                <asp:ListItem Text="18" Value="18"></asp:ListItem>
                                <asp:ListItem Text="19" Value="19"></asp:ListItem>
                                <asp:ListItem Text="20" Value="20" Selected="True"></asp:ListItem>
                                <asp:ListItem Text="21" Value="21"></asp:ListItem>
                                <asp:ListItem Text="22" Value="22"></asp:ListItem>
                                <asp:ListItem Text="23" Value="23"></asp:ListItem>
                                <asp:ListItem Text="24" Value="24"></asp:ListItem>
                            </asp:DropDownList>
                            :
                            <asp:DropDownList ID="MinutesDDL" runat="server">
                                <asp:ListItem Text="00" Value="00"></asp:ListItem>
                                <asp:ListItem Text="15" Value="15"></asp:ListItem>
                                <asp:ListItem Text="30" Value="30"></asp:ListItem>
                                <asp:ListItem Text="45" Value="45"></asp:ListItem>
                            </asp:DropDownList>
                            <asp:ImageButton ID="CopyAllImageButton" runat="server" ImageUrl="~/Images/Icons/LeaguePosition.png"
                             ToolTip="<%$ Resources:Resource, CreateTournament_FillInDates %>" OnClick="FillInTournamentDates"
                             Visible='<%# Eval("IsFirst") %>' />
                            <asp:Label ID="DateErrorLabel" runat="server" Text="*" SkinID="RedConfirmLabel" Visible="false"></asp:Label>
                        </td>
                        </tr>
                    </ItemTemplate>
                    <FooterTemplate></table></FooterTemplate>
                </asp:Repeater>
                <br /><br />
                <asp:Label ID="TournamentPrizesTitle" runat="server" skinId="InfoLabel" Text="<%$ Resources:Resource, Tournament_TournamentPricesTitle %>"></asp:Label>
                <br />
            
                <%--<asp:Repeater ID="PrizesSetRepeater" runat="server">
                    <HeaderTemplate><table></HeaderTemplate>
                    <ItemTemplate>
                        <tr>
                        <td style="vertical-align:middle;">
                            <asp:RadioButton ID="SelectedRB" runat="server" GroupName="PrizesSets" onclick='<%# "PrizesCheck(\"" + Eval("Id") + "\")" %>' />
                            <asp:HiddenField ID="OptionIdHF" runat="server" Value='<%# Eval("Id") %>' />
                        </td>
                        <td>
                            <asp:Image ID="Place1Image" runat="server" ImageUrl='<%# "~/Images/Prizes/" + Eval("Place1") %>' ToolTip="#1" Visible='<%# Eval("Place1").ToString().Length > 5 %>' />
                            <asp:Image ID="Place2Image" runat="server" ImageUrl='<%# "~/Images/Prizes/" + Eval("Place2") %>' ToolTip="#2" Visible='<%# Eval("Place2").ToString().Length > 5 %>'/>
                            <asp:Image ID="Place3Image" runat="server" ImageUrl='<%# "~/Images/Prizes/" + Eval("Place3") %>' ToolTip="#3" Visible='<%# Eval("Place3").ToString().Length > 5 %>'/>
                            <asp:Image ID="Place4Image" runat="server" ImageUrl='<%# "~/Images/Prizes/" + Eval("Place4") %>' ToolTip="#4" Visible='<%# Eval("Place4").ToString().Length > 5 %>'/>
                            <asp:Image ID="Place5Image" runat="server" ImageUrl='<%# "~/Images/Prizes/" + Eval("Place5") %>' ToolTip="#5" Visible='<%# Eval("Place5").ToString().Length > 5 %>'/>
                            <asp:Image ID="ScorerImage" runat="server" ImageUrl='<%# "~/Images/Prizes/" + Eval("Scorer") %>' 
                            ToolTip="<%$ Resources:Resource, Tournament_TopScorer %>" Visible='<%# Eval("Scorer").ToString().Length > 5 %>'/>
                            <asp:Image ID="AssisterImage" runat="server" ImageUrl='<%# "~/Images/Prizes/" + Eval("Assister") %>' 
                            ToolTip="<%$ Resources:Resource, Tournament_MostAssists %>" Visible='<%# Eval("Assister").ToString().Length > 5 %>'/>
                        </td>
                        </tr>
                    </ItemTemplate>        
                    <FooterTemplate></table></FooterTemplate>        
                </asp:Repeater>
                <asp:SqlDataSource ID="PrizesSetsDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
                        SelectCommand="Nivdal_GetTournamentPrizesOptionsWhenOpeningTournament" SelectCommandType="StoredProcedure">
                </asp:SqlDataSource>--%>


             
                <asp:Button ID="BackToStage1Button" runat="server" CssClass="GreySmallButtonStyle"
                 Text="<%$ Resources:Resource, Global_Cancel %>"  OnClick="BackToStage1" />
                 &nbsp;&nbsp;
                 <asp:Button ID="CreateTournamentButton" runat="server" Text="<%$ Resources:Resource, CreateTournament_CreateTournamentButtonText %>"
                  CssClass="GreenSmallButtonStyle" OnClick="CreateTournamentButtonClick" Message="<%$ Resources:Resource, CreateTournament_AreYouSureCreate %>"
                  OnClientClick="return confirm(this.getAttribute('Message'))" />
                  
            </asp:Panel>
            <asp:Panel ID="Stage3Panel" runat="server" Visible="false">
                <br /><br />
                <asp:Label ID="TournamentReadyLabel" runat="server" SkinID="GridLabel" Text="<%$ Resources:Resource, CreateTournament_TournamentIsReady %>"></asp:Label>
                <asp:Hyperlink ID="TournamentHyperlink" runat="server" SkinID="BlackHyperLinkSkin"></asp:Hyperlink>
                <br /><br />
                <asp:HyperLink ID="DonateTournamentPrizeLink" runat="server" Text="<%$ Resources:Resource, Tournament_DonatePremium %>" SkinID="GreenTitleHyperLink" Target="_blank" ></asp:HyperLink>
                <asp:Image ID="DonationExplanationImage" runat="server" ImageUrl="~/Images/question.gif"   />
                <cc1:Flyout ID="DonationExplanationFlyout" AttachTo="DonationExplanationImage" NoneEffect="true" runat="server">
                    <div class="ToolTipStyle" style="width:250px;">
                        <asp:Label ID="DonationExplanationLabel" runat="server" Text="<%$ Resources:Resource, Tournament_DonatePremiumExplanation %>"></asp:Label>                        
                    </div>
                </cc1:Flyout>
            

           

            </asp:Panel>
        
        </div>
        </div>
        </ContentTemplate>
    </asp:UpdatePanel>
    <asp:SqlDataSource ID="TournamentTypeDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
        SelectCommand="Nivdal_TournamentsGetTournamentTypesDDL" SelectCommandType="StoredProcedure">
    </asp:SqlDataSource>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="PageNamePlaceHolder" runat="server">
    <asp:Label ID="PageNameLabel" runat="server" Text="<%$ Resources:Resource, CreateTournament_PageTitle %>" CssClass="PageNameContentStyle"></asp:Label>    
</asp:Content>
